import 'package:flutter/material.dart';

class AlertHelper {
  static void showAlert(
      {required BuildContext context,
      String title = "",
      String? message = "",
      VoidCallback? onPressed}) {
    showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(
            title: Text(title),
            content: SingleChildScrollView(
                child: ListBody(
              children: <Widget>[
                Text(message!),
              ],
            )),
            actions: [
              TextButton(
                  onPressed: () {
                    Navigator.of(context).pop();
                  },
                  child: const Text("Cancel")),
              TextButton(
                  onPressed: () {
                    Navigator.of(context).pop();
                    if (onPressed != null) {
                      onPressed();
                    }
                  },
                  child: const Text("OK"))
            ],
          );
        });
  }
}
